<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/webjars/layui/2.5.7/css/layui.css"/>
</head>
<script src="/webjars/layui/2.5.7/layui.js"></script>
<body>
   <table id="demo" lay-filter="test"></table>
</body>
<script>

    layui.use(['table','jquery'],function(){
        var $ = layui.jquery;
        var table = layui.table;
        table.on('edit(test)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段


            $.ajax({
                url:'updateStudentById',
                data:{id:obj.data.id,
                    field:field,
                    value:obj.value},
                success:function(data){
                    if(data == 1){
                        layer.msg("xiugaichenggong ");
                    }
                }
            })

        });

        table.render({
            elem:'#demo',
            url:'/getAllStudent',
            page:true,
            cols:[
                [
                    {field:'id',title:'id'},
                    {field:'username',title:'username',edit: 'text'},
                    {field:'sex',title:'性别',edit: 'text'},{
                field:'version',title:'版本'
                }
                ]
            ]
        })
    })

</script>
</html>